import 'package:calculator/pub/config.dart';
import 'package:calculator/pub/network.dart';
import 'package:device_info/device_info.dart';

class UploadData{
  String _clientId = '';//应用唯一id
  String _phoneType = '';//机型
  String _osVersion = '';//系统版本号

  //进入应用上传此接口 统计用户活跃度
  appVestActivation() async{
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
    print('${androidInfo.androidId}');
    print('${androidInfo.device}');
    print('${androidInfo.version.release}');
    print('${androidInfo.brand}');
    // setState(() {
      _clientId = '${androidInfo.androidId}';
      _phoneType = '${androidInfo.device} === >>>  ${androidInfo.brand}';
      _osVersion = '${androidInfo.version.release}';
    // });
    var res = await Network().post('report/appVestActivation', data: {
      'appKey' : Config.appKey,
      'clientId' : _clientId,
      'phoneType' : _phoneType,
      'osVersion' : _osVersion,
    });
    int code = res['status'];
    if (code == 200) {
      print('okokokokokokoko');
    } else {
      print('errrrrror');
    }
  }

  //点击To Apply按钮传此接口，统计点击活跃度
  appBizApply(int id, int gotype) async{
    print('id === >>>>   $id');
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
    print('${androidInfo.androidId}');
    print('${androidInfo.device}');
    print('${androidInfo.version.release}');
    print('${androidInfo.brand}');
    // setState(() {
      _clientId = '${androidInfo.androidId}';
      _phoneType = '${androidInfo.device} === >>>  ${androidInfo.brand}';
      _osVersion = '${androidInfo.version.release}';
    // });
    var res = await Network().post('report/appBizApply', data: {
      'appBizId' : id,
      'appKey' : Config.appKey,
      'clientId' : _clientId,
      'phoneType' : _phoneType,
      'osVersion' : _osVersion,
      'goType' : gotype,
    });
    int code = res['status'];
    if (code == 200) {
      print('appBizApply  ===  okokokokok');
    } else {
      print('appBizApply  ===  errrrrrrror');
    }
  }
}